package com.zhisheng.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect {
    @Around("execution(* com.zhisheng.service.impl.*.*(..))")
    public Object totalTime(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        Object o = pjp.proceed();
        long end = System.currentTimeMillis();
        System.out.println(pjp.getSignature().getDeclaringTypeName()+"类中的方法"+pjp.getSignature().getName() + "执行耗时：" + (end - start) + "ms");
        return o;
    }
}
